package cn.s1995.sloth.pay.biz.plugin.stripe;

import lombok.extern.slf4j.Slf4j;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

/**
 * StripePay
 *
 * @author Lex
 * @description
 * @date 2023/12/26 09:38
 */
@Slf4j
public class StripePay {

    private static StripePay instance;
    private StripeConfig config;

    private StripePay() {
        try {
            Properties properties = new Properties();
            properties.load(new FileInputStream("stripe.properties"));

            config = new StripeConfig();
            config.setStripeKey(properties.getProperty("stripe.key"));
            config.setStripeWebHookPay(properties.getProperty("stripe.webHook.pay", ""));
            config.setStripeWebHookRefund(properties.getProperty("stripe.webHook.refund", ""));
            config.setStripeWebHookInvoice(properties.getProperty("stripe.webHook.invoice", ""));

        } catch (IOException e) {
            log.error("stripe.properties not found - {}", e);
        }
    }

    public static synchronized StripePay getInstance() {
        if (instance == null) {
            instance = new StripePay();
        }
        return instance;
    }

}
